package com.hello.common;

import com.hello.bean.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class ExceptionAdaptController {

    /**
     * 运行异常捕获
     */
    @ExceptionHandler({RuntimeException.class})
    public Result runTimeException(RuntimeException exception) {
        exception.printStackTrace();
        return Result.error();
    }
    /**
     * 其他异常捕获
     */
    @ExceptionHandler({Exception.class})
    public Result exception(Exception exception) {
        exception.printStackTrace();
        return Result.error(exception.getMessage());
    }
}
